<?php
namespace app\common\logic;

use app\common\model\CapitalWater;
use app\common\model\ShopProfit;
use think\Controller;

class Shopincome extends Controller
{
   public function get_income_list($userid,$start_time="",$end_time="",$start=0,$num=20){

           $where=[];
           if($start_time){
               $where['created_at']=['egt',$start_time];
           }

           if($end_time){
               $where['created_at']=['elt',$end_time];
           }
          return ShopProfit::where("shop_id",$userid)->where($where)->page($start,$num)->select();
   }

    public function get_business_list($userid,$start_time="",$end_time="",$start=1,$num=20){

        $where=[];
        if($start_time){
            $where['addtime']=['egt',strtotime($start_time)];
        }

        if($end_time){
            $where['addtime']=['elt',strtotime($end_time)];
        }
        if($start_time&&$end_time){
            $where['addtime']=['between',[$start_time,$end_time]];
        }
        return CapitalWater::where("shopid",$userid)->where("type",2)->where($where)->page($start,$num)->order("addtime desc")->select();
    }
}